1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.ViewStack;
26 
27 private import adw.ViewStackPage;
28 private import adw.c.functions;
29 public  import adw.c.types;
30 private import glib.ConstructionException;
31 private import glib.Str;
32 private import glib.c.functions;
33 private import gobject.ObjectG;
34 private import gtk.AccessibleIF;
35 private import gtk.AccessibleT;
36 private import gtk.BuildableIF;
37 private import gtk.BuildableT;
38 private import gtk.ConstraintTargetIF;
39 private import gtk.ConstraintTargetT;
40 private import gtk.SelectionModelIF;
41 private import gtk.Widget;
42 
43 
44 /**
45  * A view container for [class@ViewSwitcher].
46  * 
47  * `AdwViewStack` is a container which only shows one page at a time.
48  * It is typically used to hold an application's main views.
49  * 
50  * It doesn't provide a way to transition between pages.
51  * Instead, a separate widget such as [class@ViewSwitcher] can be used with
52  * `AdwViewStack` to provide this functionality.
53  * 
54  * `AdwViewStack` pages can have a title, an icon, an attention request, and a
55  * numbered badge that [class@ViewSwitcher] will use to let users identify which
56  * page is which. Set them using the [property@ViewStackPage:title],
57  * [property@ViewStackPage:icon-name],
58  * [property@ViewStackPage:needs-attention], and
59  * [property@ViewStackPage:badge-number] properties.
60  * 
61  * Unlike [class@Gtk.Stack], transitions between views are not animated.
62  * 
63  * `AdwViewStack` maintains a [class@ViewStackPage] object for each added child,
64  * which holds additional per-child properties. You obtain the
65  * [class@ViewStackPage] for a child with [method@ViewStack.get_page] and you
66  * can obtain a [iface@Gtk.SelectionModel] containing all the pages with
67  * [method@ViewStack.get_pages].
68  * 
69  * ## AdwViewStack as GtkBuildable
70  * 
71  * To set child-specific properties in a .ui file, create
72  * [class@ViewStackPage] objects explicitly, and set the child widget as a
73  * property on it:
74  * 
75  * ```xml
76  * <object class="AdwViewStack" id="stack">
77  * <child>
78  * <object class="AdwViewStackPage">
79  * <property name="name">overview</property>
80  * <property name="title">Overview</property>
81  * <property name="child">
82  * <object class="AdwStatusPage">
83  * <property name="title">Welcome!</property>
84  * </object>
85  * </property>
86  * </object>
87  * </child>
88  * </object>
89  * ```
90  * 
91  * ## CSS nodes
92  * 
93  * `AdwViewStack` has a single CSS node named `stack`.
94  *
95  * Since: 1.0
96  */
97 public class ViewStack : Widget
98 {
99 	/** the main Gtk struct */
100 	protected AdwViewStack* adwViewStack;
101 
102 	/** Get the main Gtk struct */
103 	public AdwViewStack* getViewStackStruct(bool transferOwnership = false)
104 	{
105 		if (transferOwnership)
106 			ownedRef = false;
107 		return adwViewStack;
108 	}
109 
110 	/** the main Gtk struct as a void* */
111 	protected override void* getStruct()
112 	{
113 		return cast(void*)adwViewStack;
114 	}
115 
116 	/**
117 	 * Sets our main struct and passes it to the parent class.
118 	 */
119 	public this (AdwViewStack* adwViewStack, bool ownedRef = false)
120 	{
121 		this.adwViewStack = adwViewStack;
122 		super(cast(GtkWidget*)adwViewStack, ownedRef);
123 	}
124 
125 
126 	/** */
127 	public static GType getType()
128 	{
129 		return adw_view_stack_get_type();
130 	}
131 
132 	/**
133 	 * Creates a new `AdwViewStack`.
134 	 *
135 	 * Returns: the newly created `AdwViewStack`
136 	 *
137 	 * Since: 1.0
138 	 *
139 	 * Throws: ConstructionException GTK+ fails to create the object.
140 	 */
141 	public this()
142 	{
143 		auto __p = adw_view_stack_new();
144 
145 		if(__p is null)
146 		{
147 			throw new ConstructionException("null returned by new");
148 		}
149 
150 		this(cast(AdwViewStack*) __p);
151 	}
152 
153 	/**
154 	 * Adds a child to @self.
155 	 *
156 	 * Params:
157 	 *     child = the widget to add
158 	 *
159 	 * Returns: the [class@ViewStackPage] for @child
160 	 *
161 	 * Since: 1.0
162 	 */
163 	public ViewStackPage add(Widget child)
164 	{
165 		auto __p = adw_view_stack_add(adwViewStack, (child is null) ? null : child.getWidgetStruct());
166 
167 		if(__p is null)
168 		{
169 			return null;
170 		}
171 
172 		return ObjectG.getDObject!(ViewStackPage)(cast(AdwViewStackPage*) __p);
173 	}
174 
175 	/**
176 	 * Adds a child to @self.
177 	 *
178 	 * The child is identified by the @name.
179 	 *
180 	 * Params:
181 	 *     child = the widget to add
182 	 *     name = the name for @child
183 	 *
184 	 * Returns: the `AdwViewStackPage` for @child
185 	 *
186 	 * Since: 1.0
187 	 */
188 	public ViewStackPage addNamed(Widget child, string name)
189 	{
190 		auto __p = adw_view_stack_add_named(adwViewStack, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(name));
191 
192 		if(__p is null)
193 		{
194 			return null;
195 		}
196 
197 		return ObjectG.getDObject!(ViewStackPage)(cast(AdwViewStackPage*) __p);
198 	}
199 
200 	/**
201 	 * Adds a child to @self.
202 	 *
203 	 * The child is identified by the @name. The @title will be used by
204 	 * [class@ViewSwitcher] to represent @child, so it should be short.
205 	 *
206 	 * Params:
207 	 *     child = the widget to add
208 	 *     name = the name for @child
209 	 *     title = a human-readable title for @child
210 	 *
211 	 * Returns: the `AdwViewStackPage` for @child
212 	 *
213 	 * Since: 1.0
214 	 */
215 	public ViewStackPage addTitled(Widget child, string name, string title)
216 	{
217 		auto __p = adw_view_stack_add_titled(adwViewStack, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(name), Str.toStringz(title));
218 
219 		if(__p is null)
220 		{
221 			return null;
222 		}
223 
224 		return ObjectG.getDObject!(ViewStackPage)(cast(AdwViewStackPage*) __p);
225 	}
226 
227 	/**
228 	 * Finds the child with @name in @self.
229 	 *
230 	 * Params:
231 	 *     name = the name of the child to find
232 	 *
233 	 * Returns: the requested child
234 	 *
235 	 * Since: 1.0
236 	 */
237 	public Widget getChildByName(string name)
238 	{
239 		auto __p = adw_view_stack_get_child_by_name(adwViewStack, Str.toStringz(name));
240 
241 		if(__p is null)
242 		{
243 			return null;
244 		}
245 
246 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
247 	}
248 
249 	/**
250 	 * Gets whether @self is horizontally homogeneous.
251 	 *
252 	 * Returns: whether @self is horizontally homogeneous
253 	 *
254 	 * Since: 1.0
255 	 */
256 	public bool getHhomogeneous()
257 	{
258 		return adw_view_stack_get_hhomogeneous(adwViewStack) != 0;
259 	}
260 
261 	/**
262 	 * Gets the [class@ViewStackPage] object for @child.
263 	 *
264 	 * Params:
265 	 *     child = a child of @self
266 	 *
267 	 * Returns: the page object for @child
268 	 *
269 	 * Since: 1.0
270 	 */
271 	public ViewStackPage getPage(Widget child)
272 	{
273 		auto __p = adw_view_stack_get_page(adwViewStack, (child is null) ? null : child.getWidgetStruct());
274 
275 		if(__p is null)
276 		{
277 			return null;
278 		}
279 
280 		return ObjectG.getDObject!(ViewStackPage)(cast(AdwViewStackPage*) __p);
281 	}
282 
283 	/**
284 	 * Returns a [iface@Gio.ListModel] that contains the pages of the stack.
285 	 *
286 	 * This can be used to keep an up-to-date view. The model also implements
287 	 * [iface@Gtk.SelectionModel] and can be used to track and change the visible
288 	 * page.
289 	 *
290 	 * Returns: a `GtkSelectionModel` for the stack's children
291 	 *
292 	 * Since: 1.0
293 	 */
294 	public SelectionModelIF getPages()
295 	{
296 		auto __p = adw_view_stack_get_pages(adwViewStack);
297 
298 		if(__p is null)
299 		{
300 			return null;
301 		}
302 
303 		return ObjectG.getDObject!(SelectionModelIF)(cast(GtkSelectionModel*) __p, true);
304 	}
305 
306 	/**
307 	 * Gets whether @self is vertically homogeneous.
308 	 *
309 	 * Returns: whether @self is vertically homogeneous
310 	 *
311 	 * Since: 1.0
312 	 */
313 	public bool getVhomogeneous()
314 	{
315 		return adw_view_stack_get_vhomogeneous(adwViewStack) != 0;
316 	}
317 
318 	/**
319 	 * Gets the currently visible child of @self, .
320 	 *
321 	 * Returns: the visible child
322 	 *
323 	 * Since: 1.0
324 	 */
325 	public Widget getVisibleChild()
326 	{
327 		auto __p = adw_view_stack_get_visible_child(adwViewStack);
328 
329 		if(__p is null)
330 		{
331 			return null;
332 		}
333 
334 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
335 	}
336 
337 	/**
338 	 * Returns the name of the currently visible child of @self.
339 	 *
340 	 * Returns: the name of the visible child
341 	 *
342 	 * Since: 1.0
343 	 */
344 	public string getVisibleChildName()
345 	{
346 		return Str.toString(adw_view_stack_get_visible_child_name(adwViewStack));
347 	}
348 
349 	/**
350 	 * Removes a child widget from @self.
351 	 *
352 	 * Params:
353 	 *     child = the child to remove
354 	 *
355 	 * Since: 1.0
356 	 */
357 	public void remove(Widget child)
358 	{
359 		adw_view_stack_remove(adwViewStack, (child is null) ? null : child.getWidgetStruct());
360 	}
361 
362 	/**
363 	 * Sets @self to be horizontally homogeneous or not.
364 	 *
365 	 * Params:
366 	 *     hhomogeneous = whether to make @self horizontally homogeneous
367 	 *
368 	 * Since: 1.0
369 	 */
370 	public void setHhomogeneous(bool hhomogeneous)
371 	{
372 		adw_view_stack_set_hhomogeneous(adwViewStack, hhomogeneous);
373 	}
374 
375 	/**
376 	 * Sets @self to be vertically homogeneous or not.
377 	 *
378 	 * Params:
379 	 *     vhomogeneous = whether to make @self vertically homogeneous
380 	 *
381 	 * Since: 1.0
382 	 */
383 	public void setVhomogeneous(bool vhomogeneous)
384 	{
385 		adw_view_stack_set_vhomogeneous(adwViewStack, vhomogeneous);
386 	}
387 
388 	/**
389 	 * Makes @child the visible child of @self.
390 	 *
391 	 * Params:
392 	 *     child = a child of @self
393 	 *
394 	 * Since: 1.0
395 	 */
396 	public void setVisibleChild(Widget child)
397 	{
398 		adw_view_stack_set_visible_child(adwViewStack, (child is null) ? null : child.getWidgetStruct());
399 	}
400 
401 	/**
402 	 * Makes the child with @name visible.
403 	 *
404 	 * Params:
405 	 *     name = the name of the child
406 	 *
407 	 * Since: 1.0
408 	 */
409 	public void setVisibleChildName(string name)
410 	{
411 		adw_view_stack_set_visible_child_name(adwViewStack, Str.toStringz(name));
412 	}
413 }